package com.example.yunJie.digitalSentry.control;

import com.example.yunJie.digitalSentry.entity.RecognitionEntity;
import com.example.yunJie.digitalSentry.service.RecognitionService;
import com.example.yunJie.digitalSentry.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;
import java.util.List;

@RestController
@RequestMapping("/Recognition")
public class RecognitionControl {
    @Autowired
    private RecognitionService recognitionService;

    @PostMapping("/add")
    public R<?> insert(RecognitionEntity faceDownEntity){
        if (recognitionService.insert(faceDownEntity)>0){
            return R.ok();
        }else {
            return R.fail();
        }
    }

    @RequestMapping("/update")
    public int update(RecognitionEntity faceDownEntity){
        return recognitionService.update(faceDownEntity);
    }

    @RequestMapping("/deleteById")
    public int  deleteById(int id){
        return recognitionService.deleteById(id);
    }

    @RequestMapping("/deleteIdList")
    public int  deleteIdList(List<Integer> id){
        return recognitionService.deleteIdList(id);
    }

    @RequestMapping("/findId")
    public RecognitionEntity  findId(Serializable id){
        return recognitionService.findId(id);
    }

    @RequestMapping("/findAll")
    public List<RecognitionEntity>findAll(){
        return recognitionService.findAll();
    }

}
